package vn.allmobile.ambnews.data;

import vn.allmobile.ambnews.utils.Log;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DbHelper extends SQLiteOpenHelper {		
	
    public DbHelper(Context context) {
      super(context, DbSchema.DATABASE_NAME, null, DbSchema.DATABASE_VERSION);
     
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(DbSchema.ArticleSchema.CREATE_TABLE);
        db.execSQL(DbSchema.ChanelsSchema.CREATE_TABLE);            
        // Read and populate OPML feeds            
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
      if(oldVersion < 2)
      {
    	  Log.v("Upgrading database from version " + oldVersion + " to " + newVersion);
    	  String alter_table = "ALTER TABLE " + DbSchema.ArticleSchema.TABLE_NAME + " ADD " + DbSchema.ArticleSchema.COLUMN_CONTENT + " TEXT;";
      	  db.execSQL(alter_table);
      }
    } 
}